package com.jet.chat.dbquery;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;

public class ChatQueryUsers extends ChatQueryAbstract {

	@Override
	protected ChatQueryResult main(Connection conn, ChatQueryParams chatQueryParams) throws Exception {
		HashMap<String, Integer> users = new HashMap<String, Integer>();
		
		PreparedStatement ps = conn.prepareStatement("select id, username from users");
		ResultSet results = ps.executeQuery();
		while(results.next()) {
			users.put(results.getString(2), results.getInt(1));
		}
		results.close();
		
		return new ChatQueryUsersResult(users);
	}

}
